<?php
$s['AddHead'] = '<link href="'.base_url().'css/mem/regisform_v.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" src="'.base_url().'jsc/mem/jquery-1.3.2.min.js" type="text/javascript"></script>';
$s['AddTitle']= "Edit profile";
$s['AddHeadJquery'] = '';
//remove img
$s['AddHeadJquery'] .= '
$("#remove-avatar").css("cursor","pointer");
<!-- remove avatar -->
$("#remove-avatar").click(function () { 
		$.post("'.base_url().'mem/user/removeavatar", { action: "removepic"},
		function(data){
			$("#imgavatar").hide("slow");
			$("#imgavatar").empty();
			$("#imgavatar").append("<input type=\"file\" name=\"p_avatar\" />");
			$("#imgavatar").show("fast");
		} );
    });';

//city
if($cf['p_city']){
	$s['AddHeadJquery'] .= '$("#p_state").change(function () { 
		$.post("'.base_url().'mem/sys/updateamphur", { province: $("#p_state").val()},
		function(data){
			$("#updateamphur").empty();
			$("#updateamphur").append(data);
		});
    });';
}
//birthdate
if($cf['p_birthdate']){
	$s['AddHead'] .= '
	<!-- calendar -->
<script type="text/javascript" src="'.base_url().'jsc/mem/jquery-ui-1.7.2.calendar.min.js"></script>
<link rel="stylesheet" type="text/css" href="'.base_url().'css/mem/regisform_calendar.css" />';
	$s['AddHeadJquery'] .= '$("input#p_birthdate").datepicker({ dateFormat: "dd/mm/yy",changeMonth: true,changeYear: true,minDate: "-78y",maxDate: "-5Y",defaultDate: "-30y"});';
}
// avatar
if($cf['p_avatar']){
	$s['AddHead'] .= '
	<!-- avatar -->
<script language="JavaScript" src="'.base_url().'jsc/mem/ajaxupload.3.5.js" type="text/javascript"></script>
';
$s['AddHeadJquery'] .= '
// You must create it only after the DOM is ready for manipulations
// Use $(document).ready for jquery
// document.observe("dom:loaded" for prototype
var button = $("#upload_button"), interval;
new AjaxUpload("#upload_button", {
  // Location of the server-side upload script
  // NOTE: You are not allowed to upload files to another domain
  action: "'.base_url().'pg/user/upavatar",
  // File upload name
  name: "userfile",

  // Submit file after selection
  autoSubmit: true,
  // The type of data that you"re expecting back from the server.
  // HTML (text) and XML are detected automatically.
  // Useful when you are using JSON data as a response, set to "json" in that case.
  // Also set server response type to text/html, otherwise it will not work in IE6
  responseType: false,
  // Fired after the file is selected
  // Useful when autoSubmit is disabled
  // You can return false to cancel upload
  // @param file basename of uploaded file
  // @param extension of that file
  onChange: function(file, extension){},
  // Fired before the file is uploaded
  // You can return false to cancel upload
  // @param file basename of uploaded file
  // @param extension of that file
  onSubmit: function(file, extension) {
  	button.text("Uploading");
	this.disable();
  },
  // Fired when file upload is completed
  // WARNING! DO NOT USE "FALSE" STRING AS A RESPONSE!
  // @param file basename of uploaded file
  // @param response server response
  onComplete: function(file, response) {
  	button.text("Upload completed");
  }
});
';
}
$this->load->view('mem/u_header',$s);
$this->load->view('mem/u_panel_v');
?>
<div id="stylized" class="myform">
    <form id="form" name="form" method="post" action="<?=base_url()?>mem/user/edit" <? echo $cf['p_avatar']== TRUE ? 'enctype="multipart/form-data"' : ''?> >
        <h1>Edit Profile</h1>
		<?php echo validation_errors('<div class="error-msg">', '</div>'); ?>
		<?php echo $this->upload->display_errors('<div class="error-msg">', '</div>'); ?>
		<?php 
		/// p_name ชื่อ
		if($cf['re_p_name']&& $cf['p_name']){
		?>
		<label>
            ชื่อ<span class="mark">*</span><span class="small">ตามบัตรประชาชน</span>
        </label>
        <span class="takeinput"><input type="text" name="p_name" id="p_name" <? if(isset($p_name)) echo 'value="'.$p_name.'" ';?>/> </span>
		<?
		}
		elseif(!$cf['re_p_name']&& $cf['p_name'])
		{
		?>
		<label>
            ชื่อ<span class="small">ตามบัตรประชาชน</span>
        </label>
        <span class="takeinput"><input type="text" name="p_name" id="p_name" <? if(isset($p_name)) echo 'value="'.$p_name.'" ';?>/> </span>
		<?
		}
		// p_surname นามสกุล
		if($cf['re_p_surname']&& $cf['p_surname']){
		?>
		<label>
            นามสกุล<span class="mark">*</span><span class="small">ตามบัตรประชาชน</span>
        </label>
        <span class="takeinput"><input type="text" name="p_surname" id="p_surname" <? if(isset($p_surname)) echo 'value="'.$p_surname.'" ';?>/> </span>
		<?
		}
		elseif(!$cf['re_p_surname']&& $cf['p_surname'])
		{
		?>
		<label>
            นามสกุล <span class="small">ตามบัตรประชาชน</span>
        </label>
        <span class="takeinput"><input type="text" name="p_surname" id="p_surname" <? if(isset($p_surname)) echo 'value="'.$p_surname.'" ';?>/> </span>
		<?
		}
		
		// p_gender เพศ
		if($cf['re_p_gender']&& $cf['p_gender']){
		?>
		<label>
           เพศ<span class="mark">*</span><span class="small"></span>
        </label>
       <span class="takeinput"> ชาย<input type="radio" name="p_gender" value="M" <? if(isset($p_gender) && $p_gender == 'M') echo 'checked="checked" ';?>style="width: 25px;" /> หญิง<input type="radio" name="p_gender" value="F" <? if(isset($p_gender) && $p_gender == 'F') echo 'checked="checked" ';?>style="width: 25px;" /></span>
		<?
		}
		elseif(!$cf['re_p_gender']&& $cf['p_gender'])
		{
		?>
		<label>
           เพศ <span class="small"></span>
        </label>
       <span class="takeinput"> ชาย<input type="radio" name="p_gender" value="M" <? if(isset($p_gender) && $p_gender == 'M') echo 'checked="checked" ';?>style="width: 25px;" /> หญิง<input type="radio" name="p_gender" value="F" <? if(isset($p_gender) && $p_gender == 'F') echo 'checked="checked" ';?>style="width: 25px;" /></span>
		<?
		}
		
		// birthdate วันเกิด
		if($cf['re_p_birthdate']&& $cf['p_birthdate']){
		?>
		<label>
           วันเกิด<span class="mark">*</span><span class="small">ตามบัตรประชาชน(ปี ค.ศ.)</span>
        </label>
        <span class="takeinput"><input type="text" name="p_birthdate" id="p_birthdate" <? if(isset($p_birthdate)) echo 'value="'.$p_birthdate.'" ';?>/></span>
		<?
		}
		elseif(!$cf['re_p_birthdate']&& $cf['p_birthdate'])
		{
		?>
		<label>
           วันเกิด<span class="small">ตามบัตรประชาชน(ปี ค.ศ.)</span>
        </label>
        <span class="takeinput"><input type="text" name="p_birthdate" id="p_birthdate" <? if(isset($p_birthdate)) echo 'value="'.$p_birthdate.'" ';?>/></span>
		<?
		}
		
		// p_married สถานภาพ
		if($cf['re_p_married']&& $cf['p_married']){
		?>
		<label>
       สถานภาพ<span class="mark">*</span><span class="small"></span>
        </label>
       <span class="takeinput">
       	<select id="p_married" name="p_married">
       	<?
		$list = $this->member->setp_married(0);
		foreach($list as $k => $v){
			if($p_married == $k){
				echo '<option value="'.$k.'" selected="selected">'.$v.'</option>';
			}else{
				echo '<option value="'.$k.'">'.$v.'</option>';
			}
		}
		?>
		</select>
       	</span>
		<?
		}
		elseif(!$cf['re_p_married']&& $cf['p_married'])
		{
		?>
		<label>
       สถานภาพ<span class="small"></span>
        </label>
       <span class="takeinput">
       	<select id="p_married" name="p_married">
       	<?
		$list = $this->member->Setp_married(0);
		foreach($list as $k => $v){
			if($p_married == $k){
				echo '<option value="'.$k.'" selected="selected">'.$v.'</option>';
			}else{
				echo '<option value="'.$k.'">'.$v.'</option>';
			}
		}
		?>
		</select>
		</span>
		<?
		}
		
		if($cf['re_p_address']&& $cf['p_address']){
		?>
		<label>
           ที่อยู่<span class="mark">*</span><span class="small">เพื่อประโยชน์ในการติดต่อ</span>
        </label>
        <span class="takeinput"><textarea name="p_address" id="p_address" style="width:200px;height:100px;" /><? if(isset($p_address)) echo $p_address;?></textarea></span>
		<?
		}
		elseif(!$cf['re_p_address']&& $cf['p_address'])
		{
		?>
		<label>
           ที่อยู่<span class="small">เพื่อประโยชน์ในการติดต่อ</span>
        </label>
        <span class="takeinput"><textarea name="p_address" id="p_address" style="width:200px;height:100px;" /><? if(isset($p_address)) echo $p_address;?></textarea></span>
		<?
		}
		
		if($cf['re_p_state']&& $cf['p_state']){
		?>
		<label>
           จังหวัด<span class="mark">*</span><span class="small"></span>
        </label>
        <span class="takeinput"><select name="p_state" id="p_state"> 
                <option value="">กรุณาเลือกจังหวัด</option> 
				
               <?
			   $list = $this->bee->Set_state(0);
			    foreach($list as $k => $v ){
               	if($k == $p_state){
			  		echo '<option value="'.$k.'" selected="selected">'.$v.'</option>';
			  	}
				else
				{
					echo '<option value="'.$k.'">'.$v.'</option>\n';
				}
               }
			   ?>
                </select></span>
				<?
		
		}
		elseif(!$cf['re_p_state']&& $cf['p_state'])
		{
			?>
		<label>
           จังหวัด<span class="small"></span>
        </label>
        <span class="takeinput"><select name="p_state" id="p_state"> 
                <option value="">กรุณาเลือกจังหวัด</option> 
				
               <?
			   $list = $this->bee->Set_state(0);
			    foreach($list as $k => $v ){
               	if($k == $p_state){
			  		echo '<option value="'.$k.'" selected="selected">'.$v.'</option>';
			  	}
				else
				{
					echo '<option value="'.$k.'">'.$v.'</option>\n';
				}
               }
			   ?>
                </select></span>
				<?
		}
		
		if($cf['re_p_city']&& $cf['p_city']){
		?>
		<label>
           อำเภอ<span class="mark">*</span><span class="small"></span>
        </label>
        <span class="takeinput"><span id="updateamphur">
        	<?php
			if(isset($p_city)){
				?>
				 <select name="p_city" id="p_city">
<option value="<?=$p_city?>" selected="selected"><?=$this->bee->Get_amphurname(0,$p_city)?></option>
</select>
				<?
			}
			else
			{
				?>
				 <select name="p_city" id="p_city">
<option value="0" selected="selected">อำเภอ (เลือกจังหวัดก่อน)</option>
</select>
<?
			}
			?>

</span></span>
				<?
		
		}
		elseif(!$cf['re_p_city']&& $cf['p_city'])
		{
		?>
		<label>
           อำเภอ<span class="small"></span>
        </label>
        <span class="takeinput"><span id="updateamphur">
 <?php
			if(isset($p_city)){
				?>
				 <select name="p_city" id="p_city">
<option value="<?=$p_city?>" selected="selected"><?=$this->bee->Get_amphurname(0,$p_city)?></option>
</select>
				<?
			}
			else
			{
				?>
				 <select name="p_city" id="p_city">
<option value="0" selected="selected">อำเภอ (เลือกจังหวัดก่อน)</option>
</select>
<?
			}
			?>
</span></span>
		<?
		}
		//zip
		if($cf['re_p_zip']&& $cf['p_zip']){
		?>
		<label>
           รหัสไปรษณีย์<span class="mark">*</span><span class="small"></span>
        </label>
        <span class="takeinput"><input type="text" name="p_zip" id="p_zip" <? if(isset($p_zip)) echo 'value="'.$p_zip.'" ';?>/></span>
		<?
		}
		elseif(!$cf['re_p_zip']&& $cf['p_zip'])
		{
		?>
		<label>
           รหัสไปรษณีย์ <span class="small"></span>
        </label>
        <span class="takeinput"><input type="text" name="p_zip" id="p_zip" <? if(isset($p_zip)) echo 'value="'.$p_zip.'" ';?>/></span>
		<?
		}
		
		// country
		if($cf['re_p_country']&& $cf['p_country']){
			?>
		<label>
           ประเทศ<span class="mark">*</span><span class="small"></span>
        </label>
        <span class="takeinput"><select name="p_country" id="p_country"> 
                <option value="">กรุณาเลือกประเทศ</option> 
				
               <?
			   $list = $this->bee->Set_country(0);
			    foreach($list as $k => $v ){
               	if($k == $p_country){
			  		echo '<option value="'.$k.'" selected="selected">'.$v.'</option>';
			  	}
				else
				{
					echo '<option value="'.$k.'">'.$v.'</option>\n';
				}
               }
			   ?>
                </select></span>
				<?
		}
		elseif(!$cf['re_p_country']&& $cf['p_country'])
		{
			?>
		<label>
           ประเทศ<span class="small"></span>
        </label>
        <span class="takeinput"><select name="p_country" id="p_country"> 
                <option value="">กรุณาเลือกประเทศ</option> 
				
               <?
			   $list = $this->bee->Set_country(0);
			    foreach($list as $k => $v ){
               	if($k == $p_country){
			  		echo '<option value="'.$k.'" selected="selected">'.$v.'</option>';
			  	}
				else
				{
					echo '<option value="'.$k.'">'.$v.'</option>\n';
				}
               }
			   ?>
                </select></span>
				<?
		}
		
		// telephone
		if($cf['re_p_telephone']&& $cf['p_telephone']){
		?>
		<label>
           เบอร์โทรศัพท์<span class="mark">*</span><span class="small">ที่ติดต่อได้</span>
        </label>
        <span class="takeinput"><input type="text" name="p_telephone" id="p_telephone" <? if(isset($p_telephone)) echo 'value="'.$p_telephone.'" ';?>/></span>
		<?
		}
		elseif(!$cf['re_p_telephone']&& $cf['p_telephone'])
		{
		?>
		<label>
           เบอร์โทรศัพท์<span class="small">ที่ติดต่อได้</span>
        </label>
        <span class="takeinput"><input type="text" name="p_telephone" id="p_telephone" <? if(isset($p_telephone)) echo 'value="'.$p_telephone.'" ';?>/></span>
		<?
		}
		
		// mobile phone
		if($cf['re_p_mobilephone']&& $cf['p_mobilephone']){
		?>
		<label>
           เบอร์โทรศัพท์มือถือ<span class="mark">*</span><span class="small">ที่ติดต่อได้</span>
        </label>
        <span class="takeinput"><input type="text" name="p_mobilephone" id="p_mobilephone" <? if(isset($p_mobilephone)) echo 'value="'.$p_mobilephone.'" ';?>/></span>
		<?
		}
		elseif(!$cf['re_p_mobilephone']&& $cf['p_mobilephone'])
		{
		?>
		<label>
           เบอร์โทรศัพท์มือถือ<span class="small">ที่ติดต่อได้</span>
        </label>
        <span class="takeinput"><input type="text" name="p_mobilephone" id="p_mobilephone" <? if(isset($p_mobilephone)) echo 'value="'.$p_mobilephone.'" ';?>/></span>
		<?
		}
		
		// fax number
		if($cf['re_p_fax']&& $cf['p_fax']){
		?>
		<label>
           เบอร์ Fax<span class="mark">*</span><span class="small"></span>
        </label>
        <span class="takeinput"><input type="text" name="p_fax" id="p_fax" <? if(isset($p_fax)) echo 'value="'.$p_fax.'" ';?>/></span>
		<?
		}
		elseif(!$cf['re_p_fax']&& $cf['p_fax'])
		{
		?>
		<label>
           เบอร์ Fax<span class="small"></span>
        </label>
        <span class="takeinput"><input type="text" name="p_fax" id="p_fax" <? if(isset($p_fax)) echo 'value="'.$p_fax.'" ';?>/></span>
		<?
		}
		
		//interenet
		if($cf['re_p_job']&& $cf['p_job']){
			?>
		<label>
           อาชีพ<span class="mark">*</span><span class="small"></span>
        </label>
        <span class="takeinput"><select name="p_job" id="p_job"> 
                <option value="">อาชีพ</option> 
				
               <?
			   $list = $this->member->Setp_job(0);
			    foreach($list as $k => $v ){
               	if($k == $p_job){
			  		echo '<option value="'.$k.'" selected="selected">'.$v.'</option>';
			  	}
				else
				{
					echo '<option value="'.$k.'">'.$v.'</option>\n';
				}
               }
			   ?>
                </select></span>
				<?
		}
		elseif(!$cf['re_p_job']&& $cf['p_job'])
		{
			?>
		<label>
           อาชีพ<span class="small"></span>
        </label>
        <span class="takeinput"><select name="p_job" id="p_job"> 
                <option value="">อาชีพ</option> 
				
               <?
			   $list = $this->member->Setp_job(0);
			    foreach($list as $k => $v ){
               	if($k == $p_job){
			  		echo '<option value="'.$k.'" selected="selected">'.$v.'</option>';
			  	}
				else
				{
					echo '<option value="'.$k.'">'.$v.'</option>\n';
				}
               }
			   ?>
                </select></span>
				<?
		}
		
		// MSN Email
		if($cf['re_p_msn']&& $cf['p_msn']){
		?>
		<label>
           MSN<span class="mark">*</span><span class="small">Email</span>
        </label>
        <span class="takeinput"><input type="text" name="p_msn" id="p_msn" <? if(isset($p_msn)) echo 'value="'.$p_msn.'" ';?>/></span>
		<?
		}
		elseif(!$cf['re_p_msn']&& $cf['p_msn'])
		{
		?>
		<label>
           MSN  <span class="small">Email</span>
        </label>
        <span class="takeinput"><input type="text" name="p_msn" id="p_msn" <? if(isset($p_msn)) echo 'value="'.$p_msn.'" ';?>/></span>
		<?
		}
		
		//HI5
		if($cf['re_p_hi5']&& $cf['p_hi5']){
		?>
		<label>
           HI5<span class="mark">*</span><span class="small">URL</span>
        </label>
        <span class="takeinput"><input type="text" name="p_hi5" id="p_hi5" <? if(isset($p_hi5)) echo 'value="'.$p_hi5.'" ';?>/></span>
		<?
		}
		elseif(!$cf['re_p_hi5']&& $cf['p_hi5'])
		{
		?>
		<label>
           HI5 <span class="small">URL</span>
        </label>
        <span class="takeinput"><input type="text" name="p_hi5" id="p_hi5" <? if(isset($p_hi5)) echo 'value="'.$p_hi5.'" ';?>/></span>
		<?
		}
		
		// facebook
		if($cf['re_p_facebook']&& $cf['p_facebook']){
		?>
		<label>
           Facebook <span class="mark">*</span><span class="small">URL</span>
        </label>
        <span class="takeinput"><input type="text" name="p_facebook" id="p_facebook" <? if(isset($p_facebook)) echo 'value="'.$p_facebook.'" ';?>/></span>
		<?
		}
		elseif(!$cf['re_p_facebook']&& $cf['p_facebook'])
		{
		?>
		<label>
           Facebook <span class="small">URL</span>
        </label>
        <span class="takeinput"><input type="text" name="p_facebook" id="p_facebook" <? if(isset($p_facebook)) echo 'value="'.$p_facebook.'" ';?>/></span>
		<?
		}
		
		//twitter
		if($cf['re_p_twitter']&& $cf['p_twitter']){
		?>
		<label>
           Twitter<span class="mark">*</span><span class="small">URL</span>
        </label>
        <span class="takeinput"><input type="text" name="p_twitter" id="p_twitter" <? if(isset($p_twitter)) echo 'value="'.$p_twitter.'" ';?>/></span>
		<?
		}
		elseif(!$cf['re_p_twitter']&& $cf['p_twitter'])
		{
		?>
		<label>
           Twitter <span class="small">URL</span>
        </label>
        <span class="takeinput"><input type="text" name="p_twitter" id="p_twitter" <? if(isset($p_twitter)) echo 'value="'.$p_twitter.'" ';?>/></span>
		<?
		}
		
		//URL Website
		if($cf['re_p_url']&& $cf['p_url']){
		?>
		<label>
           Website<span class="mark">*</span><span class="small">URL</span>
        </label>
        <span class="takeinput"><input type="text" name="p_url" id="p_url" <? if(isset($p_url)) echo 'value="'.$p_url.'" ';?>/></span>
		<?
		}
		elseif(!$cf['re_p_url']&& $cf['p_url'])
		{
		?>
		<label>
           Website <span class="small">URL</span>
        </label>
        <span class="takeinput"><input type="text" name="p_url" id="p_url" <? if(isset($p_url)) echo 'value="'.$p_url.'" ';?>/></span>
		<?
		}
		
		//income
		if($cf['re_p_income']&& $cf['p_income']){
			?>
		<label>
           รายได้<span class="mark">*</span><span class="small">ต่อเดือน</span>
        </label>
        <span class="takeinput"><select name="p_income" id="p_income"> 
                <option value="">รายได้</option> 
				
               <?
			   $list = $this->member->Setp_income(0);
			    foreach($list as $k => $v ){
               	if($k == $p_income){
			  		echo '<option value="'.$k.'" selected="selected">'.$v.'</option>';
			  	}
				else
				{
					echo '<option value="'.$k.'">'.$v.'</option>\n';
				}
               }
			   ?>
                </select></span>
				<?
		}
		elseif(!$cf['re_p_income']&& $cf['p_income'])
		{
			?>
		<label>
           รายได้ <span class="small">ต่อเดือน</span>
        </label>
        <span class="takeinput"><select name="p_income" id="p_income"> 
                <option value="">รายได้</option> 
				
               <?
			   $list = $this->member->Setp_income(0);
			    foreach($list as $k => $v ){
               	if($k == $p_income){
			  		echo '<option value="'.$k.'" selected="selected">'.$v.'</option>';
			  	}
				else
				{
					echo '<option value="'.$k.'">'.$v.'</option>\n';
				}
               }
			   ?>
                </select></span>
				<?
		}
		
		//interenet
		if($cf['re_p_internet']&& $cf['p_internet']){
			?>
		<label>
           สถานที่ใช้ Internet<span class="mark">*</span><span class="small">ส่วนใหญ่</span>
        </label>
        <span class="takeinput"><select name="p_internet" id="p_internet"> 
                <option value="">สถานที่ใช้ internet</option> 
				
               <?
			   $list = $this->member->Setp_internet(0);
			    foreach($list as $k => $v ){
               	if($k == $p_internet){
			  		echo '<option value="'.$k.'" selected="selected">'.$v.'</option>';
			  	}
				else
				{
					echo '<option value="'.$k.'">'.$v.'</option>\n';
				}
               }
			   ?>
                </select></span>
				<?
		}
		elseif(!$cf['re_p_internet']&& $cf['p_internet'])
		{
			?>
		<label>
           สถานที่ใช้ Internet <span class="small">ส่วนใหญ่</span>
        </label>
        <span class="takeinput"><select name="p_internet" id="p_internet"> 
                <option value="">สถานที่ใช้ internet</option> 
				
               <?
			   $list = $this->member->Setp_internet(0);
			    foreach($list as $k => $v ){
               	if($k == $p_internet){
			  		echo '<option value="'.$k.'" selected="selected">'.$v.'</option>';
			  	}
				else
				{
					echo '<option value="'.$k.'">'.$v.'</option>\n';
				}
               }
			   ?>
                </select></span>
				<?
		}
		
		//Family
		if($cf['re_p_family']&& $cf['p_family']){
		?>
		<label>
           สมาชิกในครอบครัว <span class="mark">*</span><span class="small">คน</span>
        </label>
        <span class="takeinput"><input type="text" name="p_family" id="p_family" <? if(isset($p_family)) echo 'value="'.$p_family.'" ';?>/></span>
		<?
		}
		elseif(!$cf['re_p_family']&& $cf['p_family'])
		{
		?>
		<label>
           สมาชิกในครอบครัว <span class="small">คน</span>
        </label>
        <span class="takeinput"><input type="text" name="p_family" id="p_family" <? if(isset($p_family)) echo 'value="'.$p_family.'" ';?>/></span>
		<?
		}
		
		//รหัสบัตรประชาชน
		if($cf['re_p_personalid']&& $cf['p_personalid']){
		?>
		<label>
           รหัสบัตรประชาชน<span class="mark">*</span><span class="small">ตามจริง</span>
        </label>
        <span class="takeinput"><input type="text" name="p_personalid" id="p_personalid" <? if(isset($p_personalid)) echo 'value="'.$p_personalid.'" ';?>/></span>
		<?
		}
		elseif(!$cf['re_p_personalid']&& $cf['p_personalid'])
		{
		?>
		<label>
           รหัสบัตรประชาชน <span class="small">ตามจริง</span>
        </label>
        <span class="takeinput"><input type="text" name="p_personalid" id="p_personalid" <? if(isset($p_personalid)) echo 'value="'.$p_personalid.'" ';?>/></span>
		<?
		}
		
		//รับข่าวสารทางอีเมล์
		if($cf['re_p_emailnews']&& $cf['p_emailnews']){
			?>
		<label>
           รับข่าวสารทางอีเมล์<span class="mark">*</span><span class="small"></span>
        </label>
        <span class="takeinput"><select name="p_emailnews" id="p_emailnews"> 
                <option value="">รับข่าวสารทางอีเมล์</option> 
				<option value="Y" selected="selected">รับ</option>
				<option value="N">ไม่รับ</option>\n';
                </select></span>
				<?
		}
		elseif(!$cf['re_p_emailnews']&& $cf['p_emailnews'])
		{
			?>
		<label>
           รับข่าวสารทางอีเมล์ <span class="small"></span>
        </label>
        <span class="takeinput"><select name="p_emailnews" id="p_emailnews"> 
                <option value="">รับข่าวสารทางอีเมล์</option> 
				<option value="Y" selected="selected">รับ</option>
				<option value="N">ไม่รับ</option>\n';
                </select></span>
				<?
		}
		
		//ประเภทสมาชิก
		if($cf['re_p_type']&& $cf['p_type']){
			?>
		<label>
           ประเภทของสมาชิก<span class="mark">*</span><span class="small"></span>
        </label>
        <span class="takeinput"><select name="p_type" id="p_type"> 
                <option value="">ประเภทสมาชิก</option> 
				
               <?
			   $list = $this->member->Setp_type(0);
			    foreach($list as $k => $v ){
               	if($k == $p_type){
			  		echo '<option value="'.$k.'" selected="selected">'.$v.'</option>';
			  	}
				else
				{
					echo '<option value="'.$k.'">'.$v.'</option>\n';
				}
               }
			   ?>
                </select></span>
				
				<?
		}
		elseif(!$cf['re_p_type']&& $cf['p_type'])
		{
			?>
		<label>
           ประเภทของสมาชิก <span class="small"></span>
        </label>
        <span class="takeinput"><select name="p_type" id="p_type"> 
                <option value="">ประเภทสมาชิก</option> 
				
               <?
			   $list = $this->member->Setp_type(0);
			    foreach($list as $k => $v ){
               	if($k == $p_type){
			  		echo '<option value="'.$k.'" selected="selected">'.$v.'</option>';
			  	}
				else
				{
					echo '<option value="'.$k.'">'.$v.'</option>\n';
				}
               }
			   ?>
                </select></span>
				<?
		}
		//รูปประจำตัว
		if($cf['re_p_avatar']&& $cf['p_avatar']){
			?>
		<label>
          รูปประจำตัว<span class="mark">*</span><span class="small"> .jpg .gif ไม่เกิน 500KB</span>
        </label>
        <span class="takeinput"><span id="imgavatar"><?
		if(strlen($p_avatar)>10){
			echo '<img src="'.base_url().'pgupload/'.$p_avatar.'" /> [<span id="remove-avatar">Click here to change avatar</a>]';
		}
		else
		{
			//avatar ไม่มี ต้องให้ upload
			/*$data = array(
              'name'        => 'p_avatar',
              'id'          => 'p_avatar',
            );
		echo form_upload($data);*/
		echo '<div id="upload_button">Upload</div>';
		}
?></span></span>
				<?
		}
		elseif(!$cf['re_p_avatar']&& $cf['p_avatar'])
		{
			?>
		<label>
          รูปประจำตัว<span class="small"> .jpg .gif ไม่เกิน 500KB</span>
        </label>
        <span class="takeinput"><?
		$data = array(
              'name'        => 'p_avatar',
              'id'          => 'p_avatar',
            );
		echo form_upload($data);?></span>
				<?
		}
        
		?>
		
	<label>ตรวจสอบก่อนกดส่งข้อมูล<span class="small"> </span></label>
		<span class="takeinput"><? echo form_submit('mysubmit', 'ส่งข้อมูล');?></span>
    </form>
</div>
<?php
$this->load->view('mem/u_footer');
?>